//
//  SINATecManagerItemTableViewCell.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/9.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINATecManagerItemTableViewCell.h"
#import "SINACircularBeadUtils.h"
#import "SINACalendarUtils.h"


@interface  SINATecManagerItemTableViewCell()

@property (weak, nonatomic) IBOutlet UIView *tecManagerView;
@property (weak, nonatomic) IBOutlet UILabel *statueLabel;

@property (weak, nonatomic) IBOutlet UILabel *studentNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *leaveAskTypeLabel;

@property (weak, nonatomic) IBOutlet UILabel *startTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *endTimeLabel;
@end

@implementation SINATecManagerItemTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setBackgroundColor:[UIColor colorWithHexString:@"#eeeeee"]];
    [SINACircularBeadUtils makeCircularBead:1 andView:self.tecManagerView andIsSetBackground:NO];
    [SINACircularBeadUtils makeCircularBead:5 andView:self.statueLabel andIsSetBackground:YES];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void)setModel:(SINATecManagerLeaveModel *)model{
    _model = model;
    
    
    self.studentNameLabel.text = [NSString stringWithFormat:@"%@ 提交了申请",model.realname];
    self.leaveAskTypeLabel.text = [NSString stringWithFormat:@"审批类型：%@",model.leaveTypeName];
    self.startTimeLabel.text = [NSString stringWithFormat:@"开始时间：%@",[SINACalendarUtils getDateStringWithTimeStr:model.starttime andFormat:@"yyyy-MM-dd HH:mm"]];
    self.endTimeLabel.text = [NSString stringWithFormat:@"结束时间：%@",[SINACalendarUtils getDateStringWithTimeStr:model.endtime andFormat:@"yyyy-MM-dd HH:mm"]];
    
    [self setStatueLabelBackgroundFunction:model.status];
    
    if (self.itemClickBlock) {
        [[SINAUiviewClickLiserner alloc]viewClickFunction:self.tecManagerView andWithBlick:^(UIView *view) {
            self.itemClickBlock(self.model);
        }];
    }
}

-(void) setStatueLabelBackgroundFunction:(NSInteger) index{
    if (index==1005) {
        //未通过
        [SINACircularBeadUtils makeCircularBead:0.5 andView:self.statueLabel andIsSetBackgroundColor:[UIColor colorWithHexString:@"#ff3a31"]];
        self.statueLabel.text=@"未通过";
    }else  if (index==1004) {
        //已通过
        [SINACircularBeadUtils makeCircularBead:0.5 andView:self.statueLabel andIsSetBackgroundColor:[UIColor colorWithHexString:@"#008eeb"]];
        self.statueLabel.text=@"已通过";
    }else  {
       
        //未审批
        [SINACircularBeadUtils makeCircularBead:0.5 andView:self.statueLabel andIsSetBackgroundColor:baseSelectColor];
        self.statueLabel.text=@"未审批";
    }
    
}

@end
